//
//  CZEmoticonView.swift
//  sinaSwifWeiBo
//
//  Created by 张雪雪 on 16/3/18.
//  Copyright © 2016年 张雪雪. All rights reserved.
//

import UIKit

class CZEmoticonView: UIView {

    private override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //MARK:-- 添加控件和设置属性
   private func setupUI(){
    
    addSubview(collectionView)
    addSubview(toolBarView)
    collectionView.backgroundColor = randomColor()
    toolBarView.backgroundColor = randomColor()
    
    //设置约束
    collectionView.snp_makeConstraints { (make) -> Void in
        make.left.equalTo(self.snp_left)
        make.top.equalTo(self.snp_top)
        make.right.equalTo(self.snp_right)
        make.bottom.equalTo(toolBarView.snp_top)
    }
    
   toolBarView.snp_makeConstraints { (make) -> Void in
    make.left.equalTo(self.snp_left)
    make.right.equalTo(self.snp_right)
    make.bottom.equalTo(self.snp_bottom)
    make.height.equalTo(40)
    }
    
    }
  
    //MARK: -- 懒加载
    // 上边 是用 UICollectionView 实现
    private lazy var flowLayout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
    
    private lazy var collectionView: UICollectionView = UICollectionView(frame: CGRectZero, collectionViewLayout:self.flowLayout)
    
    //下边是自定义的UIView
    private lazy var toolBarView: CZEmoticonToolBarView = CZEmoticonToolBarView()

}
